#ifndef THREAD_RALL_HPP
#define THREAD_RALL_HPP

#include<thread>
#include"xsignal/sigReciver.hpp"
class threadRALL:public sigReciver{
public:
    enum class DtorAction{join,detach};
    threadRALL(std::thread&& t,DtorAction action= DtorAction::join)
        :m_thrd(std::move(t)),m_action(action){}
    ~threadRALL(){
        if(m_thrd.joinable()){
            if(m_action == DtorAction::join)
                m_thrd.join();
            else{
                m_thrd.detach();
            }
        }
    }

    threadRALL(threadRALL&&) = default;
    threadRALL& operator=(threadRALL&&) = default;

    std::thread& get(){return m_thrd;}
private:
    std::thread m_thrd;
    DtorAction m_action;
};
#endif